<?php
//ds_department:部门表结构: 部门ID号	 部门名称
//ds_department:部门表结构:depatment_id department_name 

//ds_project:项目表结构：主键，项目编号	项目名称UTF8(40个字符)) 项目年份   项目所属部门id
//ds_project:向目表结构：	project_id 	project_name 	project_year	project_department_id

//ds_category:分类表结构：分类编号		分类名称			隶属于项目的ID
//ds_category:分类表结构：category_id	category_name 	belong_project_id 

//ds_address:网址表结构：地址编号		地址名称			网址详情			分类ID				
//ds_address:网址表结构：address_id 	address_name 	address_http 	address_cate_id 

//
//
include("config.php");
function connectDatabase() {
	//echo "mysql_connect(\"localhost\"\,$mysql_user\,$mysql_pwd\);<br>";
	$con = mysql_connect(SERVER,MYSQL_USER,MYSQL_PWD);
	if(!$con) {
		echo "Fail to connect database!<br>";
		return false;
		}
	else {
		$db_selected=@mysql_select_db(DB_NAME,$con);//
	if(!$db_selected) {
			echo "Fail to select database where  ";
			return false;
			}
		else {
			$chaset="set character_set_results=utf8";
			$result=mysql_query($chaset,$con);
			return 	$con;
			}	
		}
	}
function getAllDepartMent($con) {
		$query="select * from ds_department ";
		$result=mysql_query($query,$con);
		return $result;
}
function getProjsByDepID($depid,$con) {
		$query="select * from ds_department where project_department_id = $depid ";
		$result=mysql_query($query,$con);
		return $result;
}

	function getCatesByProjID($id,$con) {
		$query="select * from ds_category where belong_project_id = $id ";
		$result=mysql_query($query,$con);
		return $result;
	}
function getAllProject($con) {
	$query="select * from ds_project";
	$result=mysql_query($query,$con);
	return $result;
}
function getAddressUnderCate($cateid,$con) {
	$query="select * from ds_address where address_cate_id = $cateid";
	$result=mysql_query($query,$con);
	return $result;
}
function getAddrsByCateID($cateid,$con) {
	$query="select * from ds_address where  address_cate_id = $cateid";
	$result=mysql_query($query,$con);
	return $result;
}

?>
